package com.harmontronics.hanma.paas.paas.domain.releasesetup.repository.persistence;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.harmontronics.hanma.paas.paas.consts.EnvEnum;
import com.harmontronics.hanma.paas.paas.domain.releasesetup.entity.valueobject.HmReleaseRecordFields;
import com.harmontronics.hanma.paas.paas.domain.releasesetup.repository.mapper.HmReleaseSetupMapper;
import com.harmontronics.hanma.paas.paas.domain.releasesetup.repository.po.HmReleaseRecordPO;
import com.harmontronics.hanma.paas.paas.domain.releasesetup.repository.po.HmReleaseSetupPO;
import org.springframework.stereotype.Repository;


@Repository("hmReleaseSetupRepository")
public class HmReleaseSetupRepository extends ServiceImpl<HmReleaseSetupMapper, HmReleaseSetupPO> {

    public IPage<HmReleaseSetupPO> selectPage(QueryWrapper<HmReleaseSetupPO> queryWrapper, Page<HmReleaseSetupPO> page) {
        return baseMapper.selectPage(page, queryWrapper);
    }


   public HmReleaseSetupPO findByAppUnique(String appUniqueId){
        QueryWrapper<HmReleaseSetupPO> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq(HmReleaseRecordFields.APP_UNIQUE_ID,appUniqueId);
        return baseMapper.selectOne(queryWrapper);
   }

    public HmReleaseSetupPO findByAppUniqueAndSetupType(String appUniqueId, EnvEnum setupType){
        QueryWrapper<HmReleaseSetupPO> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq(HmReleaseRecordFields.APP_UNIQUE_ID,appUniqueId);
        queryWrapper.eq(HmReleaseRecordFields.SETUP_TYPE,setupType);
        return baseMapper.selectOne(queryWrapper);
    }
}